package br.com.j7.jdesk.persistence.repository.impl;

import java.util.List;

import br.com.j7.jdesk.library.exception.RepositoryException;
import br.com.j7.jdesk.persistence.entity.Enterprises;
import br.com.j7.jdesk.persistence.entity.ServicesTypes;
import br.com.j7.jdesk.persistence.repository.ServiceTypeRepository;

/**
 * 
 * 
 * @author Edivando Alves
 *
 */
public class ServiceTypeRepositoryImpl  extends AbstractRepository<ServicesTypes> implements ServiceTypeRepository{


	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#find(java.lang.Integer)
	 */
	@Override
	public ServicesTypes find(Integer id) throws RepositoryException {
		try {
			return getEntity(ServicesTypes.class, id);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.ServiceTypeRepository#findByServiceTypeAndEnterprise(java.lang.String, br.com.j7.jdesk.persistence.entity.Enterprises)
	 */
	@Override
	public ServicesTypes findByServiceTypeAndEnterprise(String cdServiceType, Enterprises enterprise) throws RepositoryException {
		try {
			return getEntity(ServicesTypes.class, "serviceTypeByCdServiceTypeAndEnterprise", cdServiceType, enterprise);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#list()
	 */
	@Override
	public List<ServicesTypes> list() throws RepositoryException {
		try {
			return listByNamedQuery(ServicesTypes.class,"serviceType");
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.ServiceTypeRepository#listByEnterprise(br.com.j7.jdesk.persistence.entity.Enterprises)
	 */
	@Override
	public List<ServicesTypes> listByEnterprise(Enterprises enterprise) throws RepositoryException {
		try {
			return listByNamedQuery(ServicesTypes.class, "serviceTypeByEnterprise", enterprise);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.ServiceTypeRepository#listByIdServiceTypePaiAndEnterprise(java.lang.Integer, br.com.j7.jdesk.persistence.entity.Enterprises)
	 */
	@Override
	public List<ServicesTypes> listByIdServiceTypePaiAndEnterprise(
			Integer idServiceTypePai, Enterprises enterprise) throws RepositoryException {
		try {
			return listByNamedQuery(ServicesTypes.class, "serviceTypeByIdServiceTypePaiAndEnterprise", 
					idServiceTypePai, enterprise);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
}
